{% extends 'myadmin/index.html' %}

{% block cont %}
<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-fl">商品添加</div>
                    <div class="widget-function am-fr">
                        <a href="javascript:;" class="am-icon-cog"></a>
                    </div>
                </div>
                <div class="widget-body am-fr">
                    <form action="{% url 'myadmin_goodsinsert' %}" class="am-form tpl-form-line-form" method="post" enctype="multipart/form-data">
                        {% csrf_token %}

                        <div class="am-form-group">
                            <label for="user-name" class="am-u-sm-3 am-form-label">选择分类
                                <span class="tpl-form-line-small-title">Title</span></label>
                            <div class="am-u-sm-9">
                                <select name="cateid" data-am-selected="{btnSize: 'sm'}" style="display: none;">
                                    {% for i in types %}
                                    <option  value="{{i.id}}" {% if i.upid == 0 %} disabled {% endif %}>{{i.newname}}{{i.name}}</option>
                                    {% endfor %}
                                    
                                </select>
                            </div>
                        </div>


                        <div class="am-form-group">
                            <label for="user-name" class="am-u-sm-3 am-form-label">商品标题
                                <span class="tpl-form-line-small-title">Title</span></label>
                            <div class="am-u-sm-9">
                                <input type="text" name="title" class="tpl-form-input" id="user-name" placeholder="请输入商品标题">
                            </div>
                        </div>

                        <div class="am-form-group">
                            <label for="user-name" class="am-u-sm-3 am-form-label">单价
                                <span class="tpl-form-line-small-title">Title</span></label>
                            <div class="am-u-sm-9">
                                <input type="text" name="price" class="tpl-form-input" id="user-name" placeholder="请输入商品单价">
                            </div>
                        </div>

                        <div class="am-form-group">
                            <label for="user-name" class="am-u-sm-3 am-form-label">库存
                                <span class="tpl-form-line-small-title">Title</span></label>
                            <div class="am-u-sm-9">
                                <input type="text" name="ordernum" class="tpl-form-input" id="user-name" placeholder="请输入您的库存数量">
                                </div>
                        </div>
                       
                        <div class="am-form-group">
                            <label for="user-weibo" class="am-u-sm-3 am-form-label">商品图片
                                <span class="tpl-form-line-small-title">Images</span></label>
                            <div class="am-u-sm-9">
                                <div class="am-form-group am-form-file">
                                    <div class="tpl-form-file-img">
                                        <img src="assets/img/a5.png" id = "img" alt="" width=100 ></div>
                                    <button type="button" class="am-btn am-btn-danger am-btn-sm">
                                        <i class="am-icon-cloud-upload"></i>添加图片</button>
                                    <input id="doc-form-file" name="g_url" class = "files" type="file" multiple=""></div>
                            </div>
                        </div>
                        <script type="text/javascript">
                             // 获取元素对象
                             // 给inp添加change事件
                            $('.files').change(function(){
                                    console.log('0')
                                    // 读取原始文件
                                    file = this.files[0];
                               
                                    var readers = new FileReader();
                                    // 读取文件
                                    readers.readAsDataURL(file)

                                    // 当文件读取完成执行获取新的url地址
                                    readers.onload=function(){
                                        
                                        $('#img').attr('src',readers.result)
                                    }
                                }
                            )
                        </script>



                        <link rel="stylesheet" type="text/css" href="/ueditor/UE/third-party/SyntaxHighlighter/shCoreDefault.css">
                        <script type="text/javascript" src="/ueditor/UE/third-party/SyntaxHighlighter/shCore.js"></script>
                        <script type="text/javascript" src="/ueditor/UE/ueditor.config.js"></script>
                        <script type="text/javascript" src="/ueditor/UE/ueditor.all.min.js"></script>
                        <script type="text/javascript" src="/ueditor/UE/lang/zh-cn/zh-cn.js"></script>

                         <div class="am-form-group">
                            <label for="user-intro" class="am-u-sm-3 am-form-label">商品简介</label>
                            <div class="am-u-sm-9">
                                <!-- <textarea name="descr" class="" rows="10" id="user-intro" placeholder="请输入商品简介"></textarea> -->
                                <!-- <script id="editor" type="text/plain" style="width:100%;height:500px;"></script> -->
                                <script id="editor" name="ginfo" type="text/plain" style="height:500px;color:#000">
                                    
                                </script>
                            </div>
                        </div>


                        <script type="text/javascript">
                            var ue = UE.getEditor('editor');
                            SyntaxHighlighter.all();
                        </script>
                       
                        
                       
                        <div class="am-form-group">
                            <div class="am-u-sm-9 am-u-sm-push-3">
                                <button  class="am-btn am-btn-primary tpl-btn-bg-color-success ">提交</button></div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
  
</div>


{% endblock %}